home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Diamond Collection / The Diamond Collection (Software Vault)(Digital Impact).ISO / cdr47 / sch250.zip / DMEDIT.PRG < prev    next >
Text File  |  1993-02-23  |  2KB  |  73 lines

  1. *****
  2. * Custom Schooner function for editing a DBEDIT routine.
  3. *****
  4. function dmedit
  5. *****
  6. * It is always a good idea to select your database whenever you
  7. * enter a DBEDIT() CUSTOM() UDF. 
  8. *****
  9. fselect("dmdemo")
  10.  
  11. *****
  12. * The Schooner CUSTOM function defines two variables for DBEDIT()
  13. *       MVPARM1=The mode of status of DBEDIT()
  14. *       MVPARM2=The current field name
  15. * It also returns one of three codes
  16. *       0 = Quit DBEDIT
  17. *       1 = Continue
  18. *       2 = Repaint screen with any changes
  19. * See DBEDIT() for more info. See also ACHOICE() and MEMOEDIT()
  20. * Use this info to design your own custom functions for DBEDIT()
  21. *****
  22. ***** Idle - no keystrokes to process *****
  23. if mvparm1=0
  24.     return 1
  25. endif
  26. ***** An empty database *****
  27. if mvparm1=3
  28.     message("Selected database is empty.","           Press ESC to exit")
  29.     return 0
  30. endif
  31. ***** Check for keystroke *****
  32. mvkeyval=lastkey()
  33.     ***** ESC key *****
  34.     if mvkeyval=27
  35.         return 0
  36.     endif
  37.     ***** ENTER key. Allow editing *****
  38.     if mvkeyval=13
  39.         mvtemp=fieldname(mvparm2)
  40.         setcursor(.t.)
  41.         if type("&mvtemp")="M"
  42.             mvscreen=savescreen(0,0,24,79)
  43.             superbox(05,10,19,70,.t.,"",.t.)
  44.             say(05,35,"EDIT NOTES")
  45.             say(19,26,"CTRL-W to Save    ESC to Exit")
  46.             mvtempmemo=memoedit(&mvtemp,06,11,18,69,.t.)
  47.             insert("&mvtemp", "mvtempmemo")
  48.             force()
  49.             restscreen(0,0,24,79,mvscreen)
  50.         else
  51.             get(row(), col(), "&mvtemp")
  52.             read
  53.         endif
  54.         setcursor(.f.)
  55.         return 1
  56.     endif
  57.     ***** DELETE key *****
  58.     * Note that file is opened exclusive. If it were opened shared, you 
  59.     * would need to lock the file/record in order to delete a record. 
  60.     * To FPACK() the file be sure to open the file exclusive. See OPEN().
  61.     *****
  62.     if mvkeyval=7
  63.         *if rlock()
  64.             delrec()
  65.             fpack()
  66.         *else
  67.         *    message("Unable to lock file for your exclusive use.")
  68.         *endif
  69.         return 2
  70.     endif
  71. ***** If an invalid key... just continue *****
  72. return 1
  73.